package com.daryl.jcu_project1_creditscoreform;

import android.os.Bundle;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.support.v4.app.NavUtils;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.RadioGroup.OnCheckedChangeListener;

public class Display_form_employment_details extends Activity {
	
	private EditText occupation;
	private EditText currentEmployerName;
	private EditText currentEmployerPhoneNumIDD;
	private EditText currentEmployerPhoneNum;
	private EditText currentEmployerFaxNumIDD;
	private EditText currentEmployerFaxNum;
	private EditText currentEmployerAdd;
	private EditText currentEmployerPostalCode;
	private EditText currentEmployerYear;
	private EditText currentEmployerMonth;
	private EditText previousEmployerName;
	private EditText previousEmployerPhoneIDD;
	private EditText previousEmployerPhone;
	private EditText previousEmployerAdd;
	private EditText previousEmployerPostalCode;
	private EditText previousOccupation;
	private EditText previousOccupationYear;
	private EditText previousOccupationMonth;
	
	private String vOccupation;
	private String vEmploymentStatus;
	private String vCurrentEmployerName;
	private String vCurrentEmployerPhoneNumIDD;
	private String vCurrentEmployerPhoneNum;
	private String vCurrentEmployerFaxNumIDD;
	private String vCurrentEmployerFaxNum;
	private String vCurrentEmployerAdd;
	private String vCurrentEmployerPostalCode;
	private String vCurrentEmployerYear;
	private String vCurrentEmployerMonth;
	private String vPreviousEmplymentStatus;
	private String vPreviousEmployerName;
	private String vPreviousEmployerPhoneIDD;
	private String vPreviousEmployerPhone;
	private String vPreviousEmployerAdd;
	private String vPreviousEmployerPostalCode;
	private String vPreviousOccupation;
	private String vPreviousOccupationYear;
	private String vPreviousOccupationMonth;
	
	private RadioGroup employmentStatusRg;
	private RadioGroup previousEmploymentStatusRg;
	
	public static int nextpage = 0;
	
	/**
	 * @uml.property  name="selection" multiplicity="(0 -1)" dimension="1"
	 */
	String[] selection = new String[]{"Add New Applicant", "Proceed To Next Page", "Cancel"};

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_display_form_employment_details);
		methods md = new methods();
		// Show the Up button in the action bar.
		Button button_next = (Button)findViewById(R.id.button_next);
		final Context context = this;
		Display_form_personal_details2 dp2 = new Display_form_personal_details2();
		
		Display_form_fund_statement df = new Display_form_fund_statement();
		
		getRadioBtnEmploymentStatus();
		getRadioBtnPreviousEmploymentStatus();
		
		if(dp2.nextpage  >0 || df.previouspage >0){
			setCustomerOccupation();
			setRadioBtnEmploymentStatus();
			setCurrentEmployerName();
			setCurrentEmployerPhoneNumIDD();
			setCurrentEmployerPhoneNum();
			setCurrentEmployerFaxNumIDD();
			setCurrentEmployerFaxNum();
			setCurrentEmployerAdd();
			setCurrentEmployerPostalCode();
			setCurrentEmployerYear();
			setCurrentEmployerMonth();
			setRadioBtnPreviousEmploymentStatus();
			setPreviousEmployerName();
			setPreviousEmployerPhoneIDD();
			setPreviousEmployerPhone();
			setPreviousEmployerAdd();
			setPreviousEmployerPostalCode();
			setPreviousOccupation();
			setPreviousOccupationYear();
			setPreviousOccupationMonth();

		}
		
		button_next.setOnClickListener(new View.OnClickListener(){
			public void onClick(View v){

				AlertDialog alert;
				AlertDialog.Builder alertBuilder = new AlertDialog.Builder(context);

				alertBuilder.setTitle("What would you like to do? ");
				alertBuilder.setItems(selection, new DialogInterface.OnClickListener() {
					
					public void onClick(DialogInterface dialog, int which) {
						if (which == 0){
							Intent intent = new Intent (getApplicationContext(), Display_form_personal_details.class);
							startActivity(intent);
						}else if(which == 1){
							Intent intent = new Intent (getApplicationContext(), Display_form_fund_statement.class);
							startActivity(intent);
							nextPage();
							onPause();
							
						}else{
							dialog.cancel();
						}
					}
				});
				alert = alertBuilder.create();
				alert.show();

			}
		});
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(
				R.menu.activity_display_form_employment_details, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		switch (item.getItemId()) {
		case android.R.id.home:
			// This ID represents the Home or Up button. In the case of this
			// activity, the Up button is shown. Use NavUtils to allow users
			// to navigate up one level in the application structure. For
			// more details, see the Navigation pattern on Android Design:
			//
			// http://developer.android.com/design/patterns/navigation.html#up-vs-back
			//
			NavUtils.navigateUpFromSameTask(this);
			return true;
		}
		return super.onOptionsItemSelected(item);
	}

	public void previousPage (View view){
		Intent intent_previous = new Intent (this, Display_form_personal_details2.class);
		methods md = new methods();
		md.editorShareIntPreferences(this, "previousPage2", 1);
		onBackPressed();
		getCustomerOccupation();
		getRadioBtnEmploymentStatus();
		getCurrentEmployerName();
		getCurrentEmployerPhoneNumIDD();
		getCurrentEmployerPhoneNum();
		getCurrentEmployerFaxNumIDD();
		getCurrentEmployerFaxNum();
		getCurrentEmployerAdd();
		getCurrentEmployerPostalCode();
		getCurrentEmployerYear();
		getCurrentEmployerMonth();
		getRadioBtnPreviousEmploymentStatus();
		getPreviousEmployerName();
		
		
		try{
		if(md.retriveSharePreference(this, vPreviousEmplymentStatus, "dPreviousEmploymentStatus").equals("No")){
			
			getPreviousEmployerName();
			getPreviousEmployerPhoneIDD();
			getPreviousEmployerPhone();
			getPreviousEmployerAdd();
			getPreviousEmployerPostalCode();
			getPreviousOccupation();
			getPreviousOccupationYear();
			getPreviousOccupationMonth();
			
		}
		
		else
			
		{
			getPreviousEmployerNameNull();
			getPreviousEmployerPhoneIDDNull();
			getPreviousEmployerPhoneNull();
			getPreviousEmployerAddNull();
			getPreviousEmployerPostalCodeNull();
			getPreviousOccupationNull();
			getPreviousOccupationYearNull();
			getPreviousOccupationMonthNull();
		}
		
		} catch (NullPointerException ex){
			System.out.println("null 1");
		}
	}
	
	public void nextPage(){
		Intent intent_previous = new Intent (this, Display_form_fund_statement.class);
		methods md = new methods();
		int retriveValue = 0;
		
		startActivity(intent_previous);
		getCustomerOccupation();
		getRadioBtnEmploymentStatus();
		getCurrentEmployerName();
		getCurrentEmployerPhoneNumIDD();
		getCurrentEmployerPhoneNum();
		getCurrentEmployerFaxNumIDD();
		getCurrentEmployerFaxNum();
		getCurrentEmployerAdd();
		getCurrentEmployerPostalCode();
		getCurrentEmployerYear();
		getCurrentEmployerMonth();	
		getRadioBtnPreviousEmploymentStatus();
		getPreviousEmployerName();
		
		if(md.retriveShareIntPreference(this,retriveValue,"previousPage3")>0){ 
			nextpage++;
		}
		
		try{
		if(md.retriveSharePreference(this, vPreviousEmplymentStatus, "dPreviousEmploymentStatus").equals("No")){
			
			getPreviousEmployerName();
			getPreviousEmployerPhoneIDD();
			getPreviousEmployerPhone();
			getPreviousEmployerAdd();
			getPreviousEmployerPostalCode();
			getPreviousOccupation();
			getPreviousOccupationYear();
			getPreviousOccupationMonth();
			
		}
		
		else
			
		{
			getPreviousEmployerNameNull();
			getPreviousEmployerPhoneIDDNull();
			getPreviousEmployerPhoneNull();
			getPreviousEmployerAddNull();
			getPreviousEmployerPostalCodeNull();
			getPreviousOccupationNull();
			getPreviousOccupationYearNull();
			getPreviousOccupationMonthNull();
		}
		
		} catch (NullPointerException ex){
			System.out.println("null 1");
		}
		
		}

	public void buttonClickNo(View view){
		TextView tx1 = (TextView)findViewById(R.id.tvPreviousEmployerDetails);
		tx1.setVisibility(View.VISIBLE);

		LinearLayout ll1 = (LinearLayout)findViewById(R.id.llPreviousEmployerName);
		ll1.setVisibility(View.VISIBLE);

		LinearLayout ll2 = (LinearLayout)findViewById(R.id.llPreviousEmployerPhoneNo);
		ll2.setVisibility(View.VISIBLE);

		LinearLayout ll3 = (LinearLayout)findViewById(R.id.llPreviousEmployerAddress);
		ll3.setVisibility(View.VISIBLE);

		LinearLayout ll4 = (LinearLayout)findViewById(R.id.llPrevioiusEmployerAddressPostcode);
		ll4.setVisibility(View.VISIBLE);

		LinearLayout ll5 = (LinearLayout)findViewById(R.id.llPreviousEmployerOccupation);
		ll5.setVisibility(View.VISIBLE);

		TextView tx2 = (TextView)findViewById(R.id.tvTimeWithYourPreviousEmployer);
		tx2.setVisibility(View.VISIBLE);

		LinearLayout ll6 = (LinearLayout)findViewById(R.id.llTimeWithYourPreviousEmployerYears);
		ll6.setVisibility(View.VISIBLE);
	}

	public void buttonClickYes(View view){
		TextView tx1 = (TextView)findViewById(R.id.tvPreviousEmployerDetails);
		tx1.setVisibility(View.GONE);

		LinearLayout ll1 = (LinearLayout)findViewById(R.id.llPreviousEmployerName);
		ll1.setVisibility(View.GONE);

		LinearLayout ll2 = (LinearLayout)findViewById(R.id.llPreviousEmployerPhoneNo);
		ll2.setVisibility(View.GONE);

		LinearLayout ll3 = (LinearLayout)findViewById(R.id.llPreviousEmployerAddress);
		ll3.setVisibility(View.GONE);

		LinearLayout ll4 = (LinearLayout)findViewById(R.id.llPrevioiusEmployerAddressPostcode);
		ll4.setVisibility(View.GONE);

		LinearLayout ll5 = (LinearLayout)findViewById(R.id.llPreviousEmployerOccupation);
		ll5.setVisibility(View.GONE);

		TextView tx2 = (TextView)findViewById(R.id.tvTimeWithYourPreviousEmployer);
		tx2.setVisibility(View.GONE);

		LinearLayout ll6 = (LinearLayout)findViewById(R.id.llTimeWithYourPreviousEmployerYears);
		ll6.setVisibility(View.GONE);
	}
	
	// get customer occupation
		public void getCustomerOccupation() {
			variables vb = new variables();
			methods md = new methods();
			occupation = (EditText) findViewById(R.id.etCurrentOccupation);
			vOccupation = occupation.getText().toString();
			
			md.editorSharePreferences(this, "dOccupation", vOccupation);
		}
		
		public void setCustomerOccupation() {

			methods md = new methods();

			occupation = (EditText) findViewById(R.id.etCurrentOccupation);
			occupation.setText(md.retriveSharePreference(this, "vOccupation",
					"dOccupation"));
			System.out.println("set occupation"
					+ md.retriveSharePreference(this, "vOccupation",
							"dOccupation"));

		}
		
		// get value in employment status radio grp
		public void getRadioBtnEmploymentStatus() {

			System.out.println("Test 121 ");
			// Gets a reference to our radio group
			// rgExistingCustomer is the name of our radio group
			employmentStatusRg = (RadioGroup) findViewById(R.id.rgEmploymentStatus1stRow);
			employmentStatusRg
					.setOnCheckedChangeListener(new OnCheckedChangeListener() {

						public void onCheckedChanged(RadioGroup group, int checkedId) {
							System.out.println("Test 122 ");
							methods md = new methods();
							variables vb = new variables();
							// Returns an integer which represents the selected
							// radio button's ID
							int selected = employmentStatusRg.getCheckedRadioButtonId();

							System.out.println(" get tested 1 " + selected);

							// Gets a reference to our "selected" radio button
							RadioButton residentStatusBtn = (RadioButton) findViewById(selected);
							// bring the selected button to variable class

							vEmploymentStatus = residentStatusBtn.getText()
									.toString();

							SharedPreferences preferences = getSharedPreferences(
									"Mb4Me", 0);
							SharedPreferences.Editor editor = preferences.edit();
							editor.putString("dEmploymentStatus", vEmploymentStatus);
							editor.putInt("dEmploymentStatusInt", selected);
							editor.commit();
							System.out.println(" get tested 1.2 " + selected);
						}

					});

		}

		// set value in resident status radio grp
		public void setRadioBtnEmploymentStatus() {

			// Gets a reference to our radio group
			// employmentStatusRg is the name of our radio group
			employmentStatusRg = (RadioGroup) findViewById(R.id.rgEmploymentStatus1stRow);

			methods md = new methods();
			variables vb = new variables();
			int selected = 0;
			// Returns an integer which represents the selected
			// radio button's ID
			// selected = residentStatus
			// .getCheckedRadioButtonId();

			System.out.println("tested1 " + selected);

			SharedPreferences preferences = getSharedPreferences("Mb4Me", 0);
			int retriveValue = md.retriveShareIntPreference(this, selected,
					"dEmploymentStatusInt");

			System.out.println("tested2 " + retriveValue);
			try{
			// sets a reference to our "selected" radio button
			RadioButton residentStatusBtn = (RadioButton) findViewById(retriveValue);
			residentStatusBtn.setChecked(true);
			}
			catch (NullPointerException ex){
				System.out.println("null 1");
			}
		}
		
		
		// get current employer name
				public void getCurrentEmployerName() {
					variables vb = new variables();
					methods md = new methods();
					currentEmployerName = (EditText) findViewById(R.id.etNameOfCurrentEmployer);
					vCurrentEmployerName = currentEmployerName.getText().toString();
					
					md.editorSharePreferences(this, "dCurrentEmployerName", vCurrentEmployerName);
				}
				
				public void setCurrentEmployerName() {

					methods md = new methods();

					currentEmployerName = (EditText) findViewById(R.id.etNameOfCurrentEmployer);
					currentEmployerName.setText(md.retriveSharePreference(this, "vCurrentEmployerName",
							"dCurrentEmployerName"));
					System.out.println("set occupation"
							+ md.retriveSharePreference(this, "vCurrentEmployerName",
									"dCurrentEmployerName"));

				}
				
				
				// get current employer phone number IDD
				public void getCurrentEmployerPhoneNumIDD() {
					variables vb = new variables();
					methods md = new methods();
					currentEmployerPhoneNumIDD = (EditText) findViewById(R.id.etEmployerPNoIDD);
					vCurrentEmployerPhoneNumIDD = currentEmployerPhoneNumIDD.getText().toString();
					
					md.editorSharePreferences(this, "dCurrentEmployerPhoneNumIDD", vCurrentEmployerPhoneNumIDD);
				}
				
				public void setCurrentEmployerPhoneNumIDD() {

					methods md = new methods();

					currentEmployerPhoneNumIDD = (EditText) findViewById(R.id.etEmployerPNoIDD);
					currentEmployerPhoneNumIDD.setText(md.retriveSharePreference(this, "vCurrentEmployerPhoneNumIDD",
							"dCurrentEmployerPhoneNumIDD"));
					System.out.println("set occupation"
							+ md.retriveSharePreference(this, "vCurrentEmployerPhoneNumIDD",
									"dCurrentEmployerPhoneNumIDD"));

				}
				
				
				// get current employer phone number 
				public void getCurrentEmployerPhoneNum() {
					variables vb = new variables();
					methods md = new methods();
					currentEmployerPhoneNum = (EditText) findViewById(R.id.etEmployerPNo);
					vCurrentEmployerPhoneNum= currentEmployerPhoneNum.getText().toString();
					
					md.editorSharePreferences(this, "dCurrentEmployerPhoneNum", vCurrentEmployerPhoneNum);
				}
				
				public void setCurrentEmployerPhoneNum() {

					methods md = new methods();

					currentEmployerPhoneNum = (EditText) findViewById(R.id.etEmployerPNo);
					currentEmployerPhoneNum.setText(md.retriveSharePreference(this, "vCurrentEmployerPhoneNum",
							"dCurrentEmployerPhoneNum"));
					System.out.println("set occupation"
							+ md.retriveSharePreference(this, "vCurrentEmployerPhoneNum",
									"dCurrentEmployerPhoneNum"));

				}
				
				
				// get current employer fax number IDD
				public void getCurrentEmployerFaxNumIDD() {
					variables vb = new variables();
					methods md = new methods();
					currentEmployerFaxNumIDD = (EditText) findViewById(R.id.etEmployerFaxNoIDD);
					vCurrentEmployerFaxNumIDD = currentEmployerFaxNumIDD.getText().toString();
					
					md.editorSharePreferences(this, "dCurrentEmployerFaxNumIDD", vCurrentEmployerFaxNumIDD);
				}
				
				public void setCurrentEmployerFaxNumIDD() {

					methods md = new methods();

					currentEmployerFaxNumIDD = (EditText) findViewById(R.id.etEmployerFaxNoIDD);
					currentEmployerFaxNumIDD.setText(md.retriveSharePreference(this, "vCurrentEmployerFaxNumIDD",
							"dCurrentEmployerFaxNumIDD"));
					System.out.println("set occupation"
							+ md.retriveSharePreference(this, "vCurrentEmployerFaxNumIDD",
									"dCurrentEmployerFaxNumIDD"));

				}
				
				
				// get current employer fax number 
				public void getCurrentEmployerFaxNum() {
					variables vb = new variables();
					methods md = new methods();
					currentEmployerFaxNum = (EditText) findViewById(R.id.etEmployerFaxNo);
					vCurrentEmployerFaxNum= currentEmployerFaxNum.getText().toString();
					
					md.editorSharePreferences(this, "dCurrentEmployerFaxNum", vCurrentEmployerFaxNum);
				}
				
				public void setCurrentEmployerFaxNum() {

					methods md = new methods();

					currentEmployerFaxNum = (EditText) findViewById(R.id.etEmployerFaxNo);
					currentEmployerFaxNum.setText(md.retriveSharePreference(this, "vCurrentEmployerFaxNum",
							"dCurrentEmployerFaxNum"));
					System.out.println("set occupation"
							+ md.retriveSharePreference(this, "vCurrentEmployerFaxNum",
									"dCurrentEmployerFaxNum"));

				}
				
				
				// get current employer address
				public void getCurrentEmployerAdd() {
					variables vb = new variables();
					methods md = new methods();
					currentEmployerAdd = (EditText) findViewById(R.id.etEmployerAddress);
					vCurrentEmployerAdd= currentEmployerAdd.getText().toString();
					
					md.editorSharePreferences(this, "dCurrentEmployerAdd", vCurrentEmployerAdd);
				}
				
				public void setCurrentEmployerAdd() {

					methods md = new methods();

					currentEmployerAdd = (EditText) findViewById(R.id.etEmployerAddress);
					currentEmployerAdd.setText(md.retriveSharePreference(this, "vCurrentEmployerAdd",
							"dCurrentEmployerAdd"));
					System.out.println("set occupation"
							+ md.retriveSharePreference(this, "vCurrentEmployerAdd",
									"dCurrentEmployerAdd"));

				}
				
				
				// get current employer postal code
				public void getCurrentEmployerPostalCode() {
					variables vb = new variables();
					methods md = new methods();
					currentEmployerPostalCode = (EditText) findViewById(R.id.etEmployerAddressPostcode);
					vCurrentEmployerPostalCode= currentEmployerPostalCode.getText().toString();
					
					md.editorSharePreferences(this, "dCurrentEmployerPostalCode", vCurrentEmployerPostalCode);
				}
				
				public void setCurrentEmployerPostalCode() {

			methods md = new methods();

			currentEmployerPostalCode = (EditText) findViewById(R.id.etEmployerAddressPostcode);
			currentEmployerPostalCode.setText(md.retriveSharePreference(this, "vCurrentEmployerPostalCode",
							"dCurrentEmployerPostalCode"));
					System.out.println("set occupation"
							+ md.retriveSharePreference(this, "vCurrentEmployerPostalCode",
									"dCurrentEmployerPostalCode"));

				}
				
				
				// get year current employer 
				public void getCurrentEmployerYear() {
					variables vb = new variables();
					methods md = new methods();
					currentEmployerYear= (EditText) findViewById(R.id.etTimeWithYourCurrentEmployerYears);
					vCurrentEmployerYear= currentEmployerYear.getText().toString();
					
					md.editorSharePreferences(this, "dCurrentEmployerYear", vCurrentEmployerYear);
				}
				
				public void setCurrentEmployerYear() {

			methods md = new methods();

			currentEmployerYear = (EditText) findViewById(R.id.etTimeWithYourCurrentEmployerYears);
			currentEmployerYear.setText(md.retriveSharePreference(this, "currentEmployerYear",
							"dCurrentEmployerYear"));
					System.out.println("set occupation"
							+ md.retriveSharePreference(this, "vCurrentEmployerYear",
									"dCurrentEmployerYear"));

				}
				
				
				// get month current employer 
				public void getCurrentEmployerMonth() {
					variables vb = new variables();
					methods md = new methods();
					currentEmployerMonth= (EditText) findViewById(R.id.etTimeWithYourCurrentEmployerMonths);
					vCurrentEmployerMonth= currentEmployerMonth.getText().toString();
					
					md.editorSharePreferences(this, "dCurrentEmployerMonth", vCurrentEmployerMonth);
				}
				
				public void setCurrentEmployerMonth() {

			methods md = new methods();

			currentEmployerMonth = (EditText) findViewById(R.id.etTimeWithYourCurrentEmployerMonths);
			currentEmployerMonth.setText(md.retriveSharePreference(this, "currentEmployerMonth",
							"dCurrentEmployerMonth"));
					System.out.println("set occupation"
							+ md.retriveSharePreference(this, "vCurrentEmployerMonth",
									"dCurrentEmployerMonth"));

				}
				
				
				// get value in previous employment status radio grp
				public void getRadioBtnPreviousEmploymentStatus() {

					System.out.println("Test 121 ");
					// Gets a reference to our radio group
					// rgExistingCustomer is the name of our radio group
					previousEmploymentStatusRg = (RadioGroup) findViewById(R.id.rgEmploymentQuestion);
					previousEmploymentStatusRg
							.setOnCheckedChangeListener(new OnCheckedChangeListener() {

								public void onCheckedChanged(RadioGroup group, int checkedId) {
									System.out.println("Test 122 ");
									methods md = new methods();
									variables vb = new variables();
									// Returns an integer which represents the selected
									// radio button's ID
									int selected = previousEmploymentStatusRg.getCheckedRadioButtonId();

									System.out.println(" get tested 1 " + selected);

									// Gets a reference to our "selected" radio button
									RadioButton residentStatusBtn = (RadioButton) findViewById(selected);
									// bring the selected button to variable class

									vPreviousEmplymentStatus = residentStatusBtn.getText()
											.toString();

									SharedPreferences preferences = getSharedPreferences(
											"Mb4Me", 0);
									SharedPreferences.Editor editor = preferences.edit();
									editor.putString("dPreviousEmploymentStatus", vPreviousEmplymentStatus);
									editor.putInt("dPreviousEmploymentStatusInt", selected);
									editor.commit();
									System.out.println(" get tested 1.2 " + selected);
									
									
								}

							});

				}

				// set value in resident status radio grp
				public void setRadioBtnPreviousEmploymentStatus() {

					// Gets a reference to our radio group
					// employmentStatusRg is the name of our radio group
					previousEmploymentStatusRg = (RadioGroup) findViewById(R.id.rgEmploymentQuestion);

					methods md = new methods();
					variables vb = new variables();
					int selected = 0;
					// Returns an integer which represents the selected
					// radio button's ID
					// selected = residentStatus
					// .getCheckedRadioButtonId();

					System.out.println("tested1 " + selected);

					SharedPreferences preferences = getSharedPreferences("Mb4Me", 0);
					int retriveValue = md.retriveShareIntPreference(this, selected,
							"dPreviousEmploymentStatusInt");

					System.out.println("tested2 " + retriveValue);
					try{
					// sets a reference to our "selected" radio button
					RadioButton residentStatusBtn = (RadioButton) findViewById(retriveValue);
					residentStatusBtn.setChecked(true);
					
					
					if(md.retriveSharePreference(this, vPreviousEmplymentStatus, "dPreviousEmploymentStatus").equals("No")){
						TextView tx1 = (TextView)findViewById(R.id.tvPreviousEmployerDetails);
						tx1.setVisibility(View.VISIBLE);

						LinearLayout ll1 = (LinearLayout)findViewById(R.id.llPreviousEmployerName);
						ll1.setVisibility(View.VISIBLE);

						LinearLayout ll2 = (LinearLayout)findViewById(R.id.llPreviousEmployerPhoneNo);
						ll2.setVisibility(View.VISIBLE);

						LinearLayout ll3 = (LinearLayout)findViewById(R.id.llPreviousEmployerAddress);
						ll3.setVisibility(View.VISIBLE);

						LinearLayout ll4 = (LinearLayout)findViewById(R.id.llPrevioiusEmployerAddressPostcode);
						ll4.setVisibility(View.VISIBLE);

						LinearLayout ll5 = (LinearLayout)findViewById(R.id.llPreviousEmployerOccupation);
						ll5.setVisibility(View.VISIBLE);

						TextView tx2 = (TextView)findViewById(R.id.tvTimeWithYourPreviousEmployer);
						tx2.setVisibility(View.VISIBLE);

						LinearLayout ll6 = (LinearLayout)findViewById(R.id.llTimeWithYourPreviousEmployerYears);
						ll6.setVisibility(View.VISIBLE);
					}
					
					else {
						TextView tx1 = (TextView)findViewById(R.id.tvPreviousEmployerDetails);
						tx1.setVisibility(View.GONE);

						LinearLayout ll1 = (LinearLayout)findViewById(R.id.llPreviousEmployerName);
						ll1.setVisibility(View.GONE);

						LinearLayout ll2 = (LinearLayout)findViewById(R.id.llPreviousEmployerPhoneNo);
						ll2.setVisibility(View.GONE);

						LinearLayout ll3 = (LinearLayout)findViewById(R.id.llPreviousEmployerAddress);
						ll3.setVisibility(View.GONE);

						LinearLayout ll4 = (LinearLayout)findViewById(R.id.llPrevioiusEmployerAddressPostcode);
						ll4.setVisibility(View.GONE);

						LinearLayout ll5 = (LinearLayout)findViewById(R.id.llPreviousEmployerOccupation);
						ll5.setVisibility(View.GONE);

						TextView tx2 = (TextView)findViewById(R.id.tvTimeWithYourPreviousEmployer);
						tx2.setVisibility(View.GONE);

						LinearLayout ll6 = (LinearLayout)findViewById(R.id.llTimeWithYourPreviousEmployerYears);
						ll6.setVisibility(View.GONE);
						
					}
					
					}
					catch (NullPointerException ex){
						System.out.println("null 1");
					
					}
				
				}
				
				// get previous employer name
				public void getPreviousEmployerName() {
					variables vb = new variables();
					methods md = new methods();
					previousEmployerName= (EditText) findViewById(R.id.etPreviousEmployerName);
					vPreviousEmployerName= previousEmployerName.getText().toString();
					
					md.editorSharePreferences(this, "dPreviousEmployerName", vPreviousEmployerName);
					
					
				}
				
				public void setPreviousEmployerName() {

			methods md = new methods();

			previousEmployerName = (EditText) findViewById(R.id.etPreviousEmployerName);
			previousEmployerName.setText(md.retriveSharePreference(this, "vPreviousEmployerName",
							"dPreviousEmployerName"));
					System.out.println("set occupation"
							+ md.retriveSharePreference(this, "vPreviousEmployerName",
									"dPreviousEmployerName"));

				}
				
				public void getPreviousEmployerNameNull() {
					
					methods md = new methods();
					md.editorSharePreferences(this, "dPreviousEmployerName", null);
					
				}
				
				
				// get previous employer phone IDD 
				public void getPreviousEmployerPhoneIDD() {
					variables vb = new variables();
					methods md = new methods();
					previousEmployerPhoneIDD= (EditText) findViewById(R.id.etPreviousEmployerPNoIDD);
					vPreviousEmployerPhoneIDD= previousEmployerPhoneIDD.getText().toString();
					
					md.editorSharePreferences(this, "dPreviousEmployerPhoneIDD", vPreviousEmployerPhoneIDD);
					
				}
				

				public void setPreviousEmployerPhoneIDD() {

			methods md = new methods();

			previousEmployerPhoneIDD = (EditText) findViewById(R.id.etPreviousEmployerPNoIDD);
			previousEmployerPhoneIDD.setText(md.retriveSharePreference(this, "vPreviousEmployerPhoneIDD",
							"dPreviousEmployerPhoneIDD"));
					System.out.println("set occupation"
							+ md.retriveSharePreference(this, "vPreviousEmployerPhoneIDD",
									"dPreviousEmployerPhoneIDD"));

				}
				
				public void getPreviousEmployerPhoneIDDNull() {
					
					methods md = new methods();
					md.editorSharePreferences(this, "dPreviousEmployerPhoneIDD", null);
					
				}
				
				
				// get previous employer phone 
				public void getPreviousEmployerPhone() {
					variables vb = new variables();
					methods md = new methods();
					previousEmployerPhone= (EditText) findViewById(R.id.etPreviousEmployerPNo);
					vPreviousEmployerPhone= previousEmployerPhone.getText().toString();
					md.editorSharePreferences(this, "dPreviousEmployerPhone", vPreviousEmployerPhone);
					
				}
				

				public void setPreviousEmployerPhone() {

			methods md = new methods();

			previousEmployerPhone = (EditText) findViewById(R.id.etPreviousEmployerPNo);
			previousEmployerPhone.setText(md.retriveSharePreference(this, "vPreviousEmployerPhone",
							"dPreviousEmployerPhone"));
					System.out.println("set occupation"
							+ md.retriveSharePreference(this, "vPreviousEmployerPhone",
									"dPreviousEmployerPhone"));

				}
				
				public void getPreviousEmployerPhoneNull() {
					
					methods md = new methods();
					md.editorSharePreferences(this, "dPreviousEmployerPhone", null);
					
				}
				
				
				
				// get previous employer address 
				public void getPreviousEmployerAdd() {
					variables vb = new variables();
					methods md = new methods();
					previousEmployerAdd= (EditText) findViewById(R.id.etPreviousEmployerAddress);
					vPreviousEmployerAdd= previousEmployerAdd.getText().toString();
					md.editorSharePreferences(this, "dPreviousEmployerAdd", vPreviousEmployerAdd);
					
				}
				

				public void setPreviousEmployerAdd() {

			methods md = new methods();

			previousEmployerAdd = (EditText) findViewById(R.id.etPreviousEmployerAddress);
			previousEmployerAdd.setText(md.retriveSharePreference(this, "vPreviousEmployerAdd",
							"dPreviousEmployerAdd"));
					System.out.println("set occupation"
							+ md.retriveSharePreference(this, "vPreviousEmployerAdd",
									"dPreviousEmployerAdd"));

				}
				
				public void getPreviousEmployerAddNull() {
					
					methods md = new methods();
					md.editorSharePreferences(this, "dPreviousEmployerAdd", null);
					
				}
				
				
				// get previous employer postal code
				public void getPreviousEmployerPostalCode() {
					variables vb = new variables();
					methods md = new methods();
					previousEmployerPostalCode= (EditText) findViewById(R.id.etPreviousEmployerAddressPostcode);
					vPreviousEmployerPostalCode= previousEmployerPostalCode.getText().toString();
					md.editorSharePreferences(this, "dPreviousEmployerPostalCode", vPreviousEmployerPostalCode);
					
				}
				

				public void setPreviousEmployerPostalCode() {

			methods md = new methods();

			previousEmployerPostalCode = (EditText) findViewById(R.id.etPreviousEmployerAddressPostcode);
			previousEmployerPostalCode.setText(md.retriveSharePreference(this, "vPreviousEmployerPostalCode",
							"dPreviousEmployerPostalCode"));
					System.out.println("set occupation"
							+ md.retriveSharePreference(this, "vPreviousEmployerPostalCode",
									"dPreviousEmployerPostalCode"));

				}
				
				public void getPreviousEmployerPostalCodeNull() {
					
					methods md = new methods();
					md.editorSharePreferences(this, "dPreviousEmployerPostalCode", null);
					
				}
				
				
				// get previous occupation
				public void getPreviousOccupation() {
					variables vb = new variables();
					methods md = new methods();
					previousOccupation= (EditText) findViewById(R.id.etPreviousEmployerOccupation);
					vPreviousOccupation= previousOccupation.getText().toString();
					md.editorSharePreferences(this, "dPreviousOccupation", vPreviousOccupation);
					
				}
				

				public void setPreviousOccupation() {

			methods md = new methods();

			previousOccupation = (EditText) findViewById(R.id.etPreviousEmployerOccupation);
			previousOccupation.setText(md.retriveSharePreference(this, "vPreviousEOccupation",
							"dPreviousOccupation"));
					System.out.println("set occupation"
							+ md.retriveSharePreference(this, "vPreviousOccupation",
									"dPreviousOccupation"));

				}
				
				public void getPreviousOccupationNull() {
					
					methods md = new methods();
					md.editorSharePreferences(this, "dPreviousOccupation", null);
					
				}
				
				
				// get previous occupation year
				public void getPreviousOccupationYear() {
					variables vb = new variables();
					methods md = new methods();
					previousOccupationYear= (EditText) findViewById(R.id.etTimeWithYourPreviousEmployerYears);
					vPreviousOccupationYear= previousOccupationYear.getText().toString();
					md.editorSharePreferences(this, "dPreviousOccupationYear", vPreviousOccupationYear);
					
				}
				

				public void setPreviousOccupationYear() {

			methods md = new methods();

			previousOccupationYear = (EditText) findViewById(R.id.etTimeWithYourPreviousEmployerYears);
			previousOccupationYear.setText(md.retriveSharePreference(this, "vPreviousEOccupationYear",
							"dPreviousOccupationYear"));
					System.out.println("set occupation"
							+ md.retriveSharePreference(this, "vPreviousOccupationYear",
									"dPreviousOccupationYear"));

				}
				
				public void getPreviousOccupationYearNull() {
					
					methods md = new methods();
					md.editorSharePreferences(this, "dPreviousOccupationYear", null);
					
				}
				
				
				// get previous occupation month
				public void getPreviousOccupationMonth() {
					variables vb = new variables();
					methods md = new methods();
					previousOccupationMonth= (EditText) findViewById(R.id.etTimeWithYourPreviousEmployerMonths);
					vPreviousOccupationMonth= previousOccupationMonth.getText().toString();
					md.editorSharePreferences(this, "dPreviousOccupationMonth", vPreviousOccupationMonth);
					
				}
				

				public void setPreviousOccupationMonth() {

			methods md = new methods();

			previousOccupationMonth = (EditText) findViewById(R.id.etTimeWithYourPreviousEmployerMonths);
			previousOccupationMonth.setText(md.retriveSharePreference(this, "vPreviousEOccupationMonth",
							"dPreviousOccupationMonth"));
					System.out.println("set occupation"
							+ md.retriveSharePreference(this, "vPreviousOccupationMonth",
									"dPreviousOccupationMonth"));

				}
				
				public void getPreviousOccupationMonthNull() {
					
					methods md = new methods();
					md.editorSharePreferences(this, "dPreviousOccupationMonth", null);
					
				}
				
				
}
